<?php
echo $header;
echo $column_left;
echo $column_right;
$width_content = '98%';
if (($column_left) && ($column_right)) {
    $width_content = '48%';
} elseif (($column_left) || ($column_right)) {
    $width_content = '73%';
}
?>
<div class="content" style="width:<?php echo $width_content; ?>"><?php echo $content_top; ?>
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
            <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
    </div>
    <?php /* if ($thumb || $description) { ?>
      <div class="category-info">
      <?php if ($thumb) { ?>
      <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></div>
      <?php } ?>
      <?php if ($description) { ?>
      <?php echo $description; ?>
      <?php } ?>
      </div>
      <?php } */ ?>
<?php if ($products) { ?>
        <div data-role="fieldcontain" class="limit">
            <select onchange="location = this.value;" data-native-menu="false">
                <?php foreach ($limits as $limits) { ?>
                    <option value="<?php echo $limits['href']; ?>"<?php echo (($limits['value'] == $limit) ? ' selected="selected"' : ''); ?>><?php echo $text_limit . ' ' . $limits['text']; ?></option>
    <?php } ?>
            </select>
        </div>

        <div data-role="fieldcontain" class="sort">
            <select onchange="location = this.value;" data-native-menu="false">
                <?php foreach ($sorts as $sorts) { ?>
                    <option value="<?php echo $sorts['href']; ?>"<?php echo (($sorts['value'] == $sort . '-' . $order) ? ' selected="selected"' : ''); ?>><?php echo $text_sort . ' ' . $sorts['text']; ?></option>
    <?php } ?>
            </select>
        </div>

        <ul data-role="listview" data-divider-theme="a" data-inset="true" class="product-list">
            <li data-role="list-divider"><?php echo $heading_title; ?></li>
                    <?php foreach ($products as $product) { ?>
                <li><a href="<?php echo $product['href']; ?>">
                        <?php if ($product['thumb']) { ?>
                            <img class="image" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" />
        <?php } ?>
                        <h3><?php echo $product['name']; ?></h3>
                        <div><span class="description"><?php echo $product['description']; ?></span><br />
                                <?php if ($product['price']) { ?>
                                <div class="price">
                                    <?php if (!$product['special']) { ?>
                                        <?php echo $product['price']; ?>
                                    <?php } else { ?>
                                        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
                                    <?php } ?>
                                    <?php if ($product['tax']) { ?>
                                        &nbsp;&nbsp;&nbsp;<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
                                <?php } ?>
                                </div>
                            <?php } ?>
                            <?php if ($product['rating']) { ?>
                                <div class="rating"><img src="catalog/view/theme/tablet/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
        <?php } ?>
                        </div>
                    </a>
                    <a href="#" onclick="addToCart('<?php echo $product['product_id']; ?>');" data-rel="dialog" data-transition="slideup"><?php echo $button_cart; ?></a></li>
    <?php } ?>
        </ul>
        <div class="Clear"><br /></div><br />

        <div class="pagination"><?php echo $pagination; ?></div>

        <div class="product-compare"><a data-role="button" href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></div>
    <?php } ?>
    <?php if (!$categories && !$products) { ?><br /><br />
    <?php echo $text_empty; ?>
        <br /><br />
        <a data-role="button" href="<?php echo $continue; ?>"><?php echo $button_continue; ?></a>
    <?php } ?>
    <?php echo $content_bottom;
    if ($categories) { ?>
        <div class="Clear"><br /></div>
        <a href="#" id="categorylist" data-role="button"><?php echo $text_refine; ?></a>
        <div class="Clear"><br /></div>
            <?php
            $scriptRefineSearch = '';
            if (count($categories) <= 5) {
                $scriptRefineSearch .= '<ul data-theme=\'a\' data-role=\'listview\'><li data-role=\'list-divider\'>' . $text_refine . '</li>';
                foreach ($categories as $category) {
                    $scriptRefineSearch .= '<li><a href=\'' . $category['href'] . '\'>' . $category['name'] . '</a></li>';
                }
                $scriptRefineSearch .= '</ul>';
            } else {
                $count_categories = count($categories);
                $scriptRefineSearch .= '<ul data-theme=\'a\' data-role=\'listview\'><li data-role=\'list-divider\'>' . $text_refine . '</li>';
                for ($i = 0; $i < $count_categories;) {
                    $j = $i + ceil($count_categories / 4);
                    for (; $i < $j; ++$i) {
                        if (isset($categories[$i])) {
                            $scriptRefineSearch .= '<li><a href=\'' . $categories[$i]['href'] . '\'>' . $categories[$i]['name'] . '</a></li>';
                        }
                    }
                }
                $scriptRefineSearch .= '</ul>';
            }
            ?>
        <script type="text/javascript">
            $(document).delegate('#categorylist', 'click', function() {
                $(this).simpledialog({
                    'mode' : 'blank',
                    'prompt': false,
                    'forceInput': false,
                    'useModal':true,
                    'fullHTML' : 
                        "<?php echo $scriptRefineSearch; ?><a rel='close' data-role='button' href='#' id='simpleclose'>Close</a>"
                })
            });
        </script>
<?php } ?>
</div>
<?php echo $footer; ?>